<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no, email=no" />
<title>苗木通讯录</title>
<include file="Public/header"/>
<style>
body {
	background:#000;
}
#clipArea {
	height: 340px;
}
</style>

</head>
<body ontouchstart="">
<article class="zzsc-container">
	<div id="clipArea"></div>
	<input type="file" id="file" name="img" />
	<button id="clipBtn" type="button">截取</button>
	<!--<div id="view"></div>-->
</article>

<script src="__PUBLIC__/photoClip/js/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/photoClip/js/iscroll-zoom.js"></script>
<script src="__PUBLIC__/photoClip/js/hammer.js"></script>
<script src="__PUBLIC__/photoClip/js/jquery.photoClip.js"></script>
<script>
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
$("#clipArea").photoClip({
	width: 300,
	height: 300,
	file: "#file",
	view: "#view",
	ok: "#clipBtn",
	loadStart: function() {
		console.log("照片读取中");
	},
	loadComplete: function() {
		console.log("照片读取完成");
	},
	clipFinish: function(dataURL) {
		console.log(dataURL);
		var url = "{:U('Index/ajaxheadimg')}";
		var postdata = {str:dataURL};
		$.post(url,postdata,function(data) {
			if(data == 1) {
				alert('头像上传成功！');
				window.location.href="{:U('Index/myself')}";
			} else {
				alert('头像上传失败！');
			}
		},'json');
	}
});
</script>
</body>
</html>
